package com.fable.sp.core.domain;

import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * .
 *
 * @author stormning on 16/7/27.
 */
@Entity
@Table(name = "sp_widget_instance")
public class WidgetInstance extends BaseEntity {

    @Column(name = "widget_name")
    private String widgetName;

    private String info;

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public String getWidgetName() {
        return widgetName;
    }

    public void setWidgetName(String widgetName) {
        this.widgetName = widgetName;
    }

    public String getDisplayName() {
        if (StringUtils.hasText(info)) {
            return info;
        } else {
            return ClassUtils.getShortName(widgetName) + "_" + getId();
        }
    }
}